using System.Collections.Generic;
using UnityEngine;
using XLua;

namespace Yoozoo.Gameplay.City
{
    public class EventDispatch
    {
        public CityRealAiEventPointInfo PointInfo { get; private set; }

        public CityRealAiEventPointInfo PerformerPointInfo { get; private set; }

        public void UpdatePointInfo(CityRealAiEventPointInfo pointInfo)
        {
            PointInfo = pointInfo;
        }

        public void UpdatePerformerPointInfo(CityRealAiEventPointInfo pointInfo)
        {
            PerformerPointInfo = pointInfo;
        }

        public void Reset()
        {
            PointInfo = null;
            PerformerPointInfo = null;
        }
    }

    public class CityRealAiEventPointInfo
    {
        public int EventId { get; private set; }
        
        /// <summary>
        /// 事件点拥有者
        /// </summary>
        public CityRealAiGoodsController Owner { get; }
        
        /// <summary>
        /// 事件点的执行者
        /// </summary>
        public CityRealAiNpcController Performer { get; private set; }
        
        /// <summary>
        /// 事件点状态
        /// </summary>
        public CityRealEventPointState State { get; private set; }
        
        /// <summary>
        /// 气泡触发次数
        /// </summary>
        public int BubbleIndex { get; private set; }
        
        /// <summary>
        /// 事件点数据
        /// </summary>
        public CityRealAiEventConfig EventConfig { get; private set; }
        
        /// <summary>
        /// 事件点场景数据
        /// </summary>
        public CityRealAiEventPointConfig PointConfig { get; private set; }

        public CityRealAiEventPointInfo()
        {
        }
        
        public CityRealAiEventPointInfo(CityRealAiGoodsController owner)
        {
            Owner = owner;
        }

        public void UpdatePointCfg(ref CityRealAiEventPointConfig pointConfig)
        {
            EventId = pointConfig.eventId;
            PointConfig = pointConfig;
            EventConfig = CityRealAiManager.GetInstance().ConfigMgr.GetAiEventConfig(EventId);
            UpdateState(CityRealEventPointState.Idle);
        }

        /// <summary>
        /// 事件点的执行者，在UpdateState之前调用
        /// </summary>
        /// <param name="performer"></param>
        public void UpdatePerformer(CityRealAiNpcController performer)
        {
            Performer = performer;
        }

        public void UpdateState(CityRealEventPointState eventState)
        {
            State = eventState;
            if (Owner != null) // 有一些动态的事件点不归属与任何事件集
            {
                Owner.UpdatePerformer(PointConfig.EventGroup, Performer);
            }
        }

        public void UpdateBubbleIndex()
        {
            BubbleIndex++;
        }

        public void Reset()
        {
            UpdatePerformer(null);
            UpdateState(CityRealEventPointState.Idle);
            BubbleIndex = 0;
        }
    }

    public class CityRealAiRoomEventInfo
    {
        public CityRealAiRoomEventConfig RoomEventConfig { get; private set; }

        public List<List<CityRealAiNpcController>> PerformerList { get; private set; }

        public List<List<Vector2>> LinkNpcInfoList { get; private set; }
        
        public bool IsNeedNpc { get; private set; }

        public CityRealAiRoomEventInfo(CityRealAiRoomEventConfig roomEventConfig)
        {
            RoomEventConfig = roomEventConfig;
        }

        public void UpdateImmediatelyPerformerList(List<List<CityRealAiNpcController>> npcCtrlList)
        {
            PerformerList = npcCtrlList;
            LinkNpcInfoList = new List<List<Vector2>>(npcCtrlList.Count);
            for (int i = 0; i < npcCtrlList.Count; i++)
            {
                var npcCtrls = npcCtrlList[i];
                var eventTree = RoomEventConfig.ex_event_tree[i];
                var linkNpcInfo = new List<Vector2>(npcCtrls.Count);
                for (int j = 0; j < npcCtrls.Count; j++)
                {
                    linkNpcInfo.Add(eventTree);
                }
                LinkNpcInfoList.Add(linkNpcInfo);
            }

            IsNeedNpc = false;
        }

        public void UpdateWaitPerformerList()
        {
            PerformerList = new List<List<CityRealAiNpcController>>(RoomEventConfig.link_npc.Length);
            LinkNpcInfoList = new List<List<Vector2>>(RoomEventConfig.link_npc.Length);
            for (int i = 0; i < RoomEventConfig.link_npc.Length; i++)
            {
                var npcCfg = RoomEventConfig.link_npc[i];
                var eventTree = RoomEventConfig.ex_event_tree[i];
                var npcList = new List<CityRealAiNpcController>((int) npcCfg.z);
                var npcInfoList = new List<Vector2>((int) npcCfg.z);
                for (int j = 0; j < npcCfg.z; j++)
                {
                    npcInfoList.Add(eventTree);
                }
                PerformerList.Add(npcList);
                LinkNpcInfoList.Add(npcInfoList);
            }

            IsNeedNpc = true;
        }

        public bool CheckNeedAndGetNpcInfo(CityRealAiNpcController npcCtrl, out Vector2 linkNpcInfo)
        {
            for (int i = 0; i < RoomEventConfig.link_npc.Length; i++)
            {
                var npcCfg = RoomEventConfig.link_npc[i];
                if ((int)npcCfg.x == (int)CityRealGetNpcConditonType.RoleTag)
                {
                    if ((int)npcCfg.y != npcCtrl.RoleTag)
                    {
                        continue;
                    }
                }
                else if ((int)npcCfg.x == (int)CityRealGetNpcConditonType.RoleType)
                {
                    if ((int)npcCfg.y != npcCtrl.RoleId)
                    {
                        continue;
                    }
                }
                else
                {
                    continue;
                }
                
                var npcList = PerformerList[i];
                if (npcList.Count < npcCfg.z) // 归位成功！
                {
                    npcList.Add(npcCtrl);
                    var npcInfoList = LinkNpcInfoList[i];
                    linkNpcInfo = npcInfoList[npcList.Count - 1];
                    return true;
                }
            }
            
            linkNpcInfo = Vector2.zero;
            return false;
        }

        public void UpdateIsNeedNpc()
        {
            for (int i = 0; i < RoomEventConfig.link_npc.Length; i++)
            {
                var npcCfg = RoomEventConfig.link_npc[i];
                var npcList = PerformerList[i];
                if (npcList.Count < npcCfg.z)
                {
                    IsNeedNpc = true;
                    return;
                }
            }

            IsNeedNpc = false;
        }

        public void OnDipose()
        {
            if (PerformerList != null)
            {
                for (int i = 0; i < PerformerList.Count; i++)
                {
                    PerformerList[i].Clear();
                }
                PerformerList.Clear();
            }

            if (LinkNpcInfoList != null)
            {
                for (int i = 0; i < LinkNpcInfoList.Count; i++)
                {
                    LinkNpcInfoList[i].Clear();;
                }
                LinkNpcInfoList.Clear();
            }

            IsNeedNpc = false;
        }
    }

    // 对应服务器存储数据 CityRealAiNpcInfo
    public class CityRealAiNpcInfo
    {
        public int cityRoleId;
        public bool isShow;
        public int buildingId;
        public bool isNew;
        public bool isSuperCustomer;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiRoomEventConfigs
    {
        public CityRealAiRoomEventConfig[] array;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiRoomEventConfig
    {
        public int room_id;
        public int room_state;
        public string event_condition;
        public Vector3[] link_npc;
        public Vector2[] ex_event_tree;
        public int ex_event_type;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiRoomBehaviorConfigs
    {
        public CityRealAiRoomBehaviorConfig[] array;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiRoomBehaviorConfig
    {
        public int room_id;
        public int role_type_id;
        public int[] default_npc_array;
        public int[] role_type_array;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiRoleInfoConfigs
    {
        public CityRealAiRoleInfoConfig[] array;
    }

    /// <summary>
    /// npc属性信息 (city_ai_npc_info)
    /// </summary>
    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiRoleInfoConfig
    {
        public int role_id; // npc id
        public int role_class;  // npc类型 1.内城普通npc 2.消费者（顾客）
        public int role_tag;    // npc标签 3固定位建筑工人
        public string model;    // 模型名称
        public int init_power;  // 初始体力，体力上限
        public int role_type;   // 默认角色执行的池子（用于索引CityRealAiRoleConfig）
        public Vector3Int[] cost_role_type;    // 一次性行为树池子
        public Vector2Int[] random_cost_num;    // 顾客随机行为次数
        public Vector3Int[] random_cost_role_type;    // 顾客随机行为树池子
        public Vector2Int[] room_role_type; // 固定房间行为树池
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiRoleConfigs
    {
        public CityRealAiRoleConfig[] array;
    }

    /// <summary>
    /// 角色类型配置 (city_ai_npc)
    /// </summary>
    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiRoleConfig
    {
        public int role_type;

        /// <summary>
        /// 主动执行事件
        /// </summary>
        public Vector2[] event_tree_array;
        
        /// <summary>
        /// 气泡事件
        /// </summary>
        public Vector3[] bubble_event_array;

        /// <summary>
        /// 气泡事件权重
        /// </summary>
        public int[] bubble_weight;

        /// <summary>
        /// 气泡事件类型
        /// </summary>
        public Vector2[] bubble_type;

        /// <summary>
        /// 条件事件
        /// </summary>
        public Vector3[] condition_event_array;

        /// <summary>
        /// 条件权重
        /// </summary>
        public int[] condition_weight;

        /// <summary>
        /// 条件事件类型
        /// </summary>
        public Vector2[] condition_type;
        
        /// <summary>
        /// 关注交互物名字
        /// </summary>
        public string[] interactive_name_array;
        
        /// <summary>
        /// 关注到交互物后触发的事件
        /// </summary>
        public Vector2[] interactive_event_array;
        
        /// <summary>
        /// 关注到交互物后触发事件的权重
        /// </summary>
        public int[] interactive_weight;
        
        /// <summary>
        /// 关注交互物的范围
        /// </summary>
        public Vector2[] interactive_type;

        /// <summary>
        /// 打断事件
        /// </summary>
        public Vector3[] break_event_array;
        
        /// <summary>
        /// 打断权重
        /// </summary>
        public int[] break_weight;
        
        /// <summary>
        /// 打断事件类型
        /// </summary>
        public Vector2[] break_type;
        
        /// <summary>
        /// 恢复体力事件
        /// </summary>
        public Vector3[] repower_event_tree_array;
        
        /// <summary>
        /// 闲置事件
        /// </summary>
        public Vector2[] idle_event_tree_array;

        /// <summary>
        /// 多次随机失败的保底事件
        /// </summary>
        public Vector2[] guarant_event_tree_array;

        /// <summary>
        /// 排队事件
        /// </summary>
        public Vector2[] waite_tree_array;

        /// <summary>
        /// 结账事件
        /// </summary>
        public Vector2[] cost_tree_array;

        /// <summary>
        /// 解锁区域事件
        /// </summary>
        public Vector2[] unlock_area_array;

        /// <summary>
        /// 前门雇员等待雇佣事件
        /// </summary>
        public Vector2[] employ_front_array;

        /// <summary>
        /// 寻路失败后，可执行的事件
        /// </summary>
        public Vector2[] faulttolerance_tree_array;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiEventTreeConfigs
    {
        public CityRealAiEventTreeConfig[] array;
    }
    
    /// <summary>
    /// 事件树配置
    /// </summary>
    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiEventTreeConfig
    {
        public int event_tree_id;

        public Vector2[] condition;

        public Vector2[] condition_or;

        public Vector3[] event_array;

        /// <summary>
        /// 默认是否可以被打断
        /// </summary>
        public bool is_interrupt;

        public Vector3 position;

        public string consumer_bubble;

        public int specialevent_group;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiEventConfigs
    {
        public CityRealAiEventConfig[] array;
    }
    
    /// <summary>
    /// 事件配置
    /// </summary>
    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiEventConfig
    {
        public int event_id;

        public int event_type;

        public Vector2[] condition;

        public Vector2[] demand;

        public string goto_ani;

        public string animation;

        public string interactive;

        public int bones_bind_interactive;

        public string wait_ani;

        public int power_change;

        /// <summary>
        /// 0 普通事件，需要设置执行事件
        /// 1 自动事件，动画结束则事件结束
        /// 2 等待事件，需要其他事件触发才能完成
        /// </summary>
        public int time_type;

        public float execute_time;

        public string parameter;

        public int bubble_hud_type;

        public int bubble_start_type;

        public Vector2 bubble_type;

        public string bubble;

        public int bones_bind_bubble;

        public float goto_speed;

        public Vector2 append_type;

        public string append;

        public int bones_bind_append;

        public int bind_positionoffset_id;

        public int clear_bubble;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiNPCBonePathConfigs
    {
        public CityRealAiNPCBonePathConfig[] array;
    }

    /// <summary>
    /// npc骨骼点配置
    /// </summary>
    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiNPCBonePathConfig
    {
        public int id;
        public string bone_path;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiNPCQueueMoodConfigs
    {
        public CityRealAiNPCQueueMoodConfig[] array;
    }

    /// <summary>
    /// npc排队生气配置
    /// </summary>
    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiNPCQueueMoodConfig
    {
        public int id;
        public int wait_time;
        public bool isdisplay;
        public int bubble_displaytime;
        public int display_progress;
        public string bubble;
        public int bones_bind_bubble;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiOperateInteractiveConfigs
    {
        public CityRealAiOperateInteractiveConfig[] array;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiOperateInteractiveConfig
    {
        public int id;
        public int type;
        public string prefab;
        public string link_point;
        public int bubble_id;
        public int clear_time;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiSpecialConfigs
    {
        public CityRealAiSpecialConfig[] array;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiSpecialConfig
    {
        public int id;
        public int priority;
        public List<Vector2Int> interrupt_event_tree;
        public int interrupt_event_type;
        public Vector2Int bind_func_type;
        public string bind_func;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiSpecialRecoverConfigs
    {
        public CityRealAiSpecialRecoverConfig[] array;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiSpecialRecoverConfig
    {
        public int id;
        public int recover_tree;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct GlobalVariablesConfig
    {
        public int cityRealAiTimeRange;
        public int cityRealAiTimeRandom;
        public int cityRealAiTimeStep;
        public int cityRealAiOutCityTimeRange;
        public int cityRealAiOutCityTimeRandom;
        public int cityRealAiOutCityTimeStep;
        public int incity_npc_ai_buswait_time_default;
        public int incity_npc_ai_downcar_num_limit;
        public int incity_npc_ai_bushidetime_num_limit;
        public int incity_npc_ai_incity_time;
        public int incity_npc_ai_outcity_time;
        public int incity_npc_ai_npcnum_buscallnow;
        public int incity_npc_ai_starttodownpoint_time;
        public int incity_npc_ai_downtouppoint_time;
        public int city_operate_rubbish_pertime;
        public int city_operate_rubbish_limit;
        public int city_operate_rubbish_trigger_basepro;
        public int city_operate_dispute_pertime;
        public int city_operate_dispute_trigger_basepro;
        public int city_operate_fix_pertime;
        public int city_operate_fix_limit;
        public int city_operate_fix_trigger_basepro;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiEventPointRoomConfigs
    {
        public CityRealAiEventPointRoomConfig[] array;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiEventPointRoomConfig
    {
        public int roomId;
        public Vector3[] birthPointPosList;
        // index = 0 InRoomPoint  index = 1 OutRoomPoint index = 2 HidePoint
        // index = 3 NpcGetOffTransportPoint1  index = 4 NpcGetOffTransportPoint2
        // index = 5 NpcGetOnTransportPoint1   index = 6 
        // index = 7 BusDownPoint1 index = 8 BusUpPoint1
        public Vector3[] specialPointPosList;
        public CityRealAiGoodsConfig[] goodsList;
        public Vector3[] MovePointList;
        public Vector3[] WaitPointPosList;
        public Vector3[] WaitPointRotList;
        public Vector3[] FrontStaffWaitPointPosList;
        public Vector3[] FrontStaffWaitPointRotList;
        public Vector3[] BackStaffWaitPointPosList;
        public Vector3[] BackStaffWaitPointRotList;
        public Vector3[][] MultiWaitPointVecPosList;
        public Vector3[][] MultiWaitPointVecRotList;
        public Vector3[] BusinessNpcJumpToRoomPointVecPosList;
        public Vector3[] BusinessNpcJumpToRoomPointVecRotList;
        public Vector3[][] OccupyAreaPointVecPosList;
        public Vector3[][] OccupyAreaPointVecRotList;
    }

    /// <summary>
    /// 交互点配置（Json转化）
    /// </summary>
    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiGoodsConfig
    {
        public string GoodsName;
        public int UnlockBuildId;
        public int UnlockLevel;
        public int FacilityId;
        public CityRealAiEventPointConfig[] pointDataList;
    }

    /// <summary>
    /// 事件点配置（Json转化）
    /// </summary>
    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiEventPointConfig
    {
        public int Index;
        public int eventId;
        public int EventGroup;
        public Vector3 Position;
        public Vector3 Rotate;
        public string GoodsTriggerName;
        public string MoveGoodsName;
        public Vector3[] MoveGoodsPosList;
        public Vector3[] MoveGoodsRotList;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiRoomDatas
    {
        public CityRealAiRoomData[] array;
    }

    [GCOptimize]
    [LuaCallCSharp]
    public struct CityRealAiRoomData
    {
        public int areaId;
        public int buildingId;
        public int index;
        public bool isDecoration;
    }

    struct CityRealHudBubbleData
    {
        public bool inUse;
        public int uid;
        public float displayTime;
        public string prefabPath;
        public int bones_bind;

        // 额外参数
        public int eventId;
        public string stringParam;
        public int param2;
        public int commodityId;
        public bool isSuperCustomer;
        
        public void Reset()
        {
            inUse = false;
            uid = 0;
            displayTime = 0;
            prefabPath = string.Empty;
            bones_bind = 0;
            eventId = 0;
            stringParam = null;
            param2 = 0;
            commodityId = 0;
            isSuperCustomer = false;
        }

        public void SetValue(int uid, string bubble, float displaytTime = -1, int bone_bind = 0, 
            int event_id = 0, string stringParam = null, int param2 = 0, int commodityId = 0, bool isSuperCustomer = false)
        {
            inUse = true;
            this.uid = uid;
            prefabPath = bubble;
            displayTime = displaytTime;
            if (bone_bind == 0)
            {
                bones_bind = CityRealAiConst.BubbleProgressBarBone;
            }
            else
            {
                bones_bind = bone_bind;
            }
            eventId = event_id;
            this.stringParam = stringParam;
            this.param2 = param2;
            this.commodityId = commodityId;
            this.isSuperCustomer = isSuperCustomer;
        }
    }

    public class RoomParameterInfo
    {
        public int ParameterValue { get; }
        public List<int> TriggerNpcUidList { get; }

        public RoomParameterInfo(int parameterValue)
        {
            ParameterValue = parameterValue;
            TriggerNpcUidList = new List<int>();
        }
    }

    public struct SpecialBreakInfo
    {
        public int SpecialId;
        public int SpecialGroupId;
        public CityRealAiSpecialConfig Config;
        public int AdditionValue;
        public bool KillOtherBubble;
    }
    
    public enum ConditionType
    {
        Event = 1,
        Tree = 2,
    }

    public enum EventExecuteAction
    {
        Room                      = 1,
        AreaRandom                = 2,
        Area                      = 3,
        AreaRandomOnly            = 4,
        Idle                      = 5,  // 原地
        BackStaffWaitQueue        = 6,  // 后门雇员队列
        FrontStaffWaitQueue       = 7,  // 前门雇员队列
    }

    public enum CityRealRoomNavigateArea
    {
        InRoom                          = 0, // 房间内寻路、表现
        RoomExternal                    = 1, // 房间内的内容，但是在外部寻路、表现
    }

    public enum CityRealEventTreeState
    {
        None                      = 0, // 尚未初始化
        WaitMoveRoom              = 1, // 等待进入房间
        InProgress                = 2, // 进行中
        ExecuteFailed             = 3, // 执行失败
        ExecuteSuccess            = 4, // 执行成功
        LeaveRoom                 = 5, // 离开房间
    }

    // HUD类型
    public enum CityRealEventBubbleHudType
    {
        Common = 1, // 普通气泡
        Skill = 2, // 技能气泡
        ProgressBar = 3, // 进度条气泡
        Commodity = 4, // 商品气泡
        Staff = 5, // 雇员气泡
        Effect = 6, // 特效
        Dialogue = 7,   // 对话气泡
    }

    // 气泡触发类型
    public enum CityRealEventBubbleStartType
    {
        AnimationEvent = 1, // 动画事件触发
        EventStart = 2, // 事件开始时触发
        EventEnd = 3, // 事件结束时触发
    }

    public enum CityRealEventTreeType
    {
        None                         = 0, //  未在执行事件
        DrivingEventTree             = 1, //  主动事件树            根据默认值看是否可以被打断
        ConditonEventTree            = 2, //  关注后执行的条件事件树 不可被打断
        BreakEventTree               = 3, //  关注后执行的打断事件树 不可被打断
        RepowerEventTree             = 4, //  恢复体力事件树         根据默认值看体力是否足够，可被打断
        IdleEventTree                = 5, //  闲置事件树             根据默认值看是否可以被打断
        SpecialEventTree             = 6, //  房间的特殊事件树       不可以被打断
        WaitQueueEventTree           = 7, //  排队事件树             根据默认值看是否可以被打断
        MoveGoodsTriggerEventTree    = 8, //  关注交互物触发事件     根据默认值看是否可以被打断
        SpecialEndEventTree          = 9, //  房间的结束特殊事件     根据默认值看是否可以被打断
        SerarchPathFailedEventTree   = 10, // 多次寻路失败后执行事件 根据默认值看是否可以被打断
        CostEventTree                = 11, // 结账事件树
        BubbbleSpecialTree           = 12, // 气泡引发的特殊事件
        BubbleEventTree              = 13, // 关注气泡触发事件
        UnlockAreaEventTree          = 14, // 解锁区域事件
        FrontEmployEventTree         = 15, // 前门雇员等待雇佣事件
        GuarantEventTree             = 16, // 多次随机失败的保底事件
    }

    public enum CityRealEventPointState
    {
        Idle                           = 0, // 空闲
        Move                           = 1, // 有人正在去执行
        Wait                           = 2, // 等待
        Work                           = 3, // 忙碌
    }

    public enum CityRealEventBreakType
    {
        Failed                       = 1, // 失败
        Replace                      = 2, // 替换
        Branch                       = 3, // 分支
        Jump                         = 4, // 跳过
        SuccessToNew                 = 5, // 某件事执行成功，则开始一个新的事件树，延续之前树的类型
        SuccessToNewIdle             = 6, // 某件事执行成功，则开始一个新的事件树，树类型重置为Idle
    }

    public enum CityRealNpcType
    {
        AreaNpc                = 1, // 区域NPC
        RoomNpc                = 2, // 房间NPC
    }
    
    /// <summary>
    /// 小人身份
    /// </summary>
    public enum CityRealNpcClassType
    {
        Normal = 1, // 内城npc
        Customer = 2,   // 顾客
        Staff = 3,//雇员
        DJ = 4, // DJ
        Babe = 5,   // 美女
    }

    /// <summary>
    /// 开门营业类型
    /// </summary>
    public enum CityBusinessType
    {
        None = 0,   // 无
        Manual = 1, // 主动营业
        Auto = 2,   // 自动营业
    }

    public enum CityRealEventTimeType
    {
        MoveTime                     = -1, // 移动时间
        NormalTime                   = 0,  // 普通时间
        AutoTime                     = 1,  // 自动时间
        WaitTime                     = 2,  // 等待时间
    }

    public enum CityRealEventConditionType
    {
        ExistEvent                        = 1, // 交互点中存在某个正在执行的事件
        CurrentEventTree                  = 2, // 自己是否正在执行的树
        CurrentDailyStage                 = 3, // 当前处于昼夜系统那个阶段
    }

    public enum CityRealEventType
    {
        NormalEvent               = 1,
        SpecialEvent              = 2,
    }

    public enum CityRealRoomEventExecuteType
    {
        Immediately                         = 1, // 立即执行
        Wait                                = 2, // 等待执行
    }

    public enum CityRealRoomStateChangeEvent
    {
        StartUpgrade                        = 1,  // 开始升级
        EndUpgrade                          = 2,  // 结束升级
        StartTrain                          = 3,  // 开始训练
        EndTrain                            = 4,  // 结束训练
        ExistWoundedSoldier                 = 5,  // 存在伤兵
        NotWoundedSoldier                   = 6,  // 不存在伤兵
        StartTreat                          = 7,  // 开始治疗
        EndTreat                            = 15, // 结束治疗
        BeforeLecture                       = 8,  // 开始讲课准备
        StartLecture                        = 9,  // 开始讲课
        EndLecture                          = 10, // 结束讲课
        StartReinforce                      = 11, // 开始增援
        EndReinforece                       = 12, // 结束增援
        StartAssembly                       = 13, // 开始集结
        EndAssembly                         = 14, // 结束集结
        StartResearch                       = 16, // 开始研究
        EndResearch                         = 17, // 结束研究
    }

    public enum CityRealRoomState
    {
        Upgrade                  = 1 << 0, // 1 建造/升级中
        Train                    = 1 << 1, // 2 训练中
        Lecture                  = 1 << 2, // 4 讲课中
        Treat                    = 1 << 3, // 8 治疗中
        Reinforce                = 1 << 4, // 16 增援中
        Assembly                 = 1 << 5, // 32 集结中
        Wounded                  = 1 << 6, // 64 存在伤兵
        Research                 = 1 << 7, // 128 研究中
    }

    public enum CityRealGetNpcConditonType
    {
        RoleTag                            = 1, // 角色标签
        RoleType                           = 2, // 角色类型
    }

    public enum CityRealNpcFocusType
    {
        Room                        = 1, // 关注房间内事件点
        Goods                       = 2, // 只关注自己所在事件集内事件点
    }

    public enum CityRealNpcBirthType
    {
        Alive                       = 0, // 直接显示
        Hide                        = 1, // 隐藏中
        Lock                        = 2, // 未解锁
    }

    public enum CityRealNpcEffectTriggerType
    {
        StartEvent                          = 1, // 事件开始时触发
        AniTagEvent                         = 2, // 动画标签触发
    }

    public enum CityRealWallState
    {
        None                           = 0, // 初始状态
        BusInCityGetOffTransportPoint  = 1, // 巴士进入内城直达下车点
        NpcGetOffTransport             = 2, // 巴士内npc下车
        BusInCityGetOnTransportPoint   = 3, // 巴士进入内城直达上车点
        BusToGetOnTransportPoint       = 4, // 巴士从下车点到上车点
        NpcGetOnTransport              = 5, // 车站内npc上车
        BusOutCity                     = 6, // 巴士离开内城
        BusHide                        = 7, // 巴士隐藏
    }

    /**
     * 开门营业消费者巴士状态
     */
    public enum CityRealCustomerBusState
    {
        None = 0,   // 无
        Parking,    // 停车
        OutCity,    // 出城
    }
    
}